调整为获取前一个小时段内的最高体温

FFIB 3 years ago
parent
commit
3fb46d2206
2 changed files with 15 additions and 2 deletions
  1. 2 1
      api/eqpt_views.py
  2. 13 1
      equipment/models.py

+ 2 - 1
api/eqpt_views.py

@@ -153,6 +153,7 @@ def eqpt_result(request):
153 153
     logs = ThermometerMeasureInfo.objects.filter(
154 154
         point_id=point_id,
155 155
         point_measure_ymd=tc.local_string(format='%Y-%m-%d'),
156
+        point_measure_window=point.previous_measure_window,
156 157
         macid__in=macids,
157 158
         status=True,
158 159
     ).values('macid', 'temperature')
@@ -199,7 +200,7 @@ def screen_eqpt_result(request):
199 200
     logs = ThermometerMeasureInfo.objects.filter(
200 201
         point_id=point_id,
201 202
         point_measure_ymd=tc.local_string(format='%Y-%m-%d'),
202
-        point_measure_window=point.point_measure_window,
203
+        point_measure_window=point.previous_measure_window,
203 204
         macid__in=macids,
204 205
         status=True,
205 206
     ).values('macid', 'temperature')

+ 13 - 1
equipment/models.py

@@ -118,7 +118,19 @@ class IsolationPointInfo(BaseModelMixin):
118 118
             start_t, end_t = window.get('start'), window.get('end')
119 119
             start_dt = tc.string_to_utc_datetime(f'{current_ymd} {start_t}:00')
120 120
             end_dt = tc.string_to_utc_datetime(f'{current_ymd} {end_t}:00')
121
-            if tc.utc_datetime(start_dt, minutes=-30) < current_dt < tc.utc_datetime(end_dt, minutes=30):
121
+            if tc.utc_datetime(start_dt) < current_dt < tc.utc_datetime(end_dt):
122
+                return f'{start_t}-{end_t}'
123
+        return ''
124
+    
125
+    @property
126
+    def previous_measure_window(self):
127
+        current_ymd = tc.local_string(format='%Y-%m-%d')
128
+        current_dt = tc.utc_datetime()
129
+        for window in self.point_measure_window:
130
+            start_t, end_t = window.get('start'), window.get('end')
131
+            start_dt = tc.string_to_utc_datetime(f'{current_ymd} {start_t}:00')
132
+            end_dt = tc.string_to_utc_datetime(f'{current_ymd} {end_t}:00')
133
+            if tc.utc_datetime(start_dt, minutes=60) < current_dt < tc.utc_datetime(end_dt, minutes=60):
122 134
                 return f'{start_t}-{end_t}'
123 135
         return ''
124 136